# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=pathlib
pkgbase=mingw-w64-python2-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-python2-${_realname}"
pkgver=1.0.1
pkgrel=1
pkgdesc="This module offers a set of classes featuring all the common operations on paths in an easy, object-oriented way"
arch=('any')
url="https://pathlib.readthedocs.org/en/${pkgver}/"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python2")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=("https://files.pythonhosted.org/packages/source/p/pathlib/pathlib-${pkgver}.tar.gz")
sha512sums=('d85e45dfcc85ce75a7e7b609163dc8c75c688f279c1833510185f280af5501e473376dc09bddc6a804d1fcc3177a939db85af37b7b8d5b183b9bc2b85b3b0f8b')

prepare() {
  cd "${srcdir}"
  rm -rf python2-build-${CARCH}| true
  cp -r "${_realname}-${pkgver}" "python2-build-${CARCH}"
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
}

build() {
    msg "Python 2 build for ${CARCH}"
    cd "${srcdir}/python2-build-${CARCH}"
    ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
     --root="${pkgdir}" --optimize='1' --skip-build
  install -Dm644 LICENSE.txt "$pkgdir${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE.txt"
}
